package org.opu.db.obj.vis.ui.client.tablerenders;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.opu.db.obj.vis.domain.domains.AbstractEntity;
import org.opu.db.obj.vis.domain.domains.AbstractAttributeEntry;
import org.opu.db.obj.vis.domain.domains.AttributePriority;
import org.opu.db.obj.vis.domain.domains.ObjectEntry;
import org.opu.db.obj.vis.domain.domains.ObjectPriority;
import org.opu.db.obj.vis.ui.client.BeanView;

public class TableRenderAttribute implements TableRender<AbstractAttributeEntry> {

	public static final Object[] COLUMN_NAMES;
	public static final Class<?>[] TYPES = new Class<?>[] {
        Object.class,
        String.class,
        String.class,
        List.class
    };

    static {
//        PublicationI18N i18n = new PublicationI18N();
        COLUMN_NAMES = new Object[]{
//                    i18n.get("secondName", "Second name"),
//                    i18n.get("name", "Name"),
//                    i18n.get("lastName", "Last name"),
//                    i18n.get("isStudent", "Student")
            "Table", "Name", "Description"//, "ObjectPriority"
                };
    }

	@Override
	public Class<AbstractAttributeEntry> getRenderingClass() {
		return AbstractAttributeEntry.class;
	}

	@Override
	public void rendView(Collection<? extends AbstractEntity> beans, BeanView view) {
		Object[][] rowData = new Object[beans.size()][4];

		int i = 0;
		for (AbstractEntity tb : beans) {
			AbstractAttributeEntry bean = (AbstractAttributeEntry) tb;
			rowData[i][0] = bean.getId().getObjectEntry().getId();
			rowData[i][1] = bean.getId().getName();
			rowData[i][2] = bean.getDescription();
            
            ArrayList<AttributePriority> prioritys = bean.getPrioritys();
//			rowData[i][3] = prioritys; // TODO:
            i++;
		}
		view.setContent(COLUMN_NAMES, TYPES, rowData);
	}

}
